class: center, middle, inverse, title-slide # Introduction to R for Data Analysis ## Outlook ### Johannes Breuer & Stefan Jünger ### 2021-08-06 --- layout: true --- ## Recap: Course schedule - Day 1 <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Topic </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> Monday </td> <td style="text-align:left;color: gray !important;"> 10:30 - 11:30 </td> <td style="text-align:left;font-weight: bold;"> Getting Started with R and RStudio </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Monday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 11:30 - 11:45 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Monday </td> <td style="text-align:left;color: gray !important;"> 11:45 - 12:45 </td> <td style="text-align:left;font-weight: bold;"> Getting Started with R and RStudio </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Monday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:45 - 13:45 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Monday </td> <td style="text-align:left;color: gray !important;"> 13:45 - 15:00 </td> <td style="text-align:left;font-weight: bold;"> Data Import & Export </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Monday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 15:00 - 15:15 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Monday </td> <td style="text-align:left;color: gray !important;"> 15:15 - 16:30 </td> <td style="text-align:left;font-weight: bold;"> Data Import & Export </td> </tr> </tbody> </table> --- ## Recap: Course schedule - Day 2 <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Topic </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> Tuesday </td> <td style="text-align:left;color: gray !important;"> 10:00 - 11:15 </td> <td style="text-align:left;font-weight: bold;"> Data Wrangling - Basics </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Tuesday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 11:15 - 11:30 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Tuesday </td> <td style="text-align:left;color: gray !important;"> 11:30 - 12:45 </td> <td style="text-align:left;font-weight: bold;"> Data Wrangling - Basics </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Tuesday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:45 - 13:45 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Tuesday </td> <td style="text-align:left;color: gray !important;"> 13:45 - 15:00 </td> <td style="text-align:left;font-weight: bold;"> Data Wrangling - Advanced </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Tuesday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 15:00 - 15:15 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Tuesday </td> <td style="text-align:left;color: gray !important;"> 15:15 - 16:30 </td> <td style="text-align:left;font-weight: bold;"> Data Wrangling - Advanced </td> </tr> </tbody> </table> --- ## Recap: Course schedule - Day 3 <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Topic </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> Wednesday </td> <td style="text-align:left;color: gray !important;"> 10:00 - 11:15 </td> <td style="text-align:left;font-weight: bold;"> Exploratory Data Analysis </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Wednesday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 11:15 - 11:30 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Wednesday </td> <td style="text-align:left;color: gray !important;"> 11:30 - 12:45 </td> <td style="text-align:left;font-weight: bold;"> Exploratory Data Analysis </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Wednesday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:45 - 13:45 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Wednesday </td> <td style="text-align:left;color: gray !important;"> 13:45 - 15:00 </td> <td style="text-align:left;font-weight: bold;"> Data Visualization - Part 1 </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Wednesday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 15:00 - 15:15 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Wednesday </td> <td style="text-align:left;color: gray !important;"> 15:15 - 16:30 </td> <td style="text-align:left;font-weight: bold;"> Data Visualization - Part 1 </td> </tr> </tbody> </table> --- ## Recap: Course schedule - Day 4 <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Topic </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> Thursday </td> <td style="text-align:left;color: gray !important;"> 10:00 - 11:15 </td> <td style="text-align:left;font-weight: bold;"> Confirmatory Data Analysis </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Thursday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 11:15 - 11:30 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Thursday </td> <td style="text-align:left;color: gray !important;"> 11:30 - 12:45 </td> <td style="text-align:left;font-weight: bold;"> Confirmatory Data Analysis </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Thursday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:45 - 13:45 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Thursday </td> <td style="text-align:left;color: gray !important;"> 13:45 - 15:00 </td> <td style="text-align:left;font-weight: bold;"> Data Visualization - Part 2 </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Thursday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 15:00 - 15:15 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Thursday </td> <td style="text-align:left;color: gray !important;"> 15:15 - 16:30 </td> <td style="text-align:left;font-weight: bold;"> Data Visualization - Part 2 </td> </tr> </tbody> </table> --- ## Recap: Course schedule - Day 5 <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Time </th> <th style="text-align:left;"> Topic </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;color: gray !important;"> Friday </td> <td style="text-align:left;color: gray !important;"> 10:00 - 11:15 </td> <td style="text-align:left;font-weight: bold;"> Reporting with R Markdown </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Friday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 11:15 - 11:30 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Friday </td> <td style="text-align:left;color: gray !important;"> 11:30 - 12:45 </td> <td style="text-align:left;font-weight: bold;"> Reporting with R Markdown </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Friday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 12:45 - 13:45 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Lunch Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Friday </td> <td style="text-align:left;color: gray !important;"> 13:45 - 15:00 </td> <td style="text-align:left;font-weight: bold;"> Advanced Use of R, Outlook, Q&A </td> </tr> <tr> <td style="text-align:left;color: gray !important;color: gray !important;"> Friday </td> <td style="text-align:left;color: gray !important;color: gray !important;"> 15:00 - 15:15 </td> <td style="text-align:left;font-weight: bold;color: gray !important;"> Break </td> </tr> <tr> <td style="text-align:left;color: gray !important;"> Friday </td> <td style="text-align:left;color: gray !important;"> 15:15 - 16:30 </td> <td style="text-align:left;font-weight: bold;"> Advanced Use of R, Outlook, Q&A </td> </tr> </tbody> </table> --- ## Where to go from here? Hopefully, after this week, you feel prepared to do your next steps in `R`. Some recommendations for continuing your jou`R`ney: - Keep up working with `R`! - If time permits, do stuff you usually do in `SPSS` or `Stata` in `R`, even when it's harder - Try to do at least one research task solely in `R` (one analysis, a whole paper, a report, etc.) - Look for tutorials and guides online - trust us, there's way more (good & free) online material for `R` than there is, e.g., for `SPSS` or `Stata` --- ## Working with other data types Both Johannes and Stefan use different data types in their daily work: - digital trace data (Johannes)<sup>*</sup> - georeferenced/geospatial data (Stefan)<sup>**</sup> **Remember that `R` is data-agnostic! It can serve as a fancy data science tool for extracting social media data but also as a full-blown Geographic Information System (GIS)** .footnote[ [*] See, e.g., https://github.com/jobreu/twitter-linking-workshop-2021] .footnote[ [**] See, e.g., https://github.com/StefanJuenger/gesis-workshop-geospatial-techniques-R] --- ## Geospatial data .pull-left[ ```r library(mapsf) mtq <- mf_get_mtq() mf_map(x = mtq) mf_map(x = mtq, var = "POP", type = "prop") mf_layout( title = "Population in Martinique", credits = "T. Giraud; Sources: INSEE & IGN, 2018" ) ``` ] .pull-right[ <img src="data:image/png;base64,#5_2_Outlook_files/figure-html/mapsf-print-1.png" style="display: block; margin: auto;" /> ] Example from: https://riatelab.github.io/mapsf/ --- ## 'Web development' using `R` These days, a lot of `R` packages provides tool originally developed for the web. For example: - [bookdown](https://cran.r-project.org/web/packages/bookdown/index.html) enables you to publish your book written in `R Markdown` online - [pkgdown](https://cran.r-project.org/web/packages/pkgdown/index.html) does the same for your own `R` package - [blogdown](https://cran.r-project.org/web/packages/blogdown/index.html) is more general and helps you with creating websites (example to follow) --- ## Shiny apps > Shiny is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards. You can also extend your Shiny apps with CSS themes, htmlwidgets, and JavaScript actions. https://shiny.rstudio.com/ --- ## Example 1: --- ## Example 2: --- ## Creating your own homepage with `R` .pull-left[ <img src="data:image/png;base64,#C:\Users\breuerjs\Documents\Lehre\r-intro-gesis-2021\content\img\homepage_johannes.png" width="1319" style="display: block; margin: auto;" /> .center[.small[https://www.johannesbreuer.com/]] ] .pull-right[ <img src="data:image/png;base64,#C:\Users\breuerjs\Documents\Lehre\r-intro-gesis-2021\content\img\homepage_stefan.png" width="1315" style="display: block; margin: auto;" /> .center[.small[https://stefanjuenger.github.io/]] ] --- ## Acknowledgements ❤️ All slides were created with the `R` package [`xaringan`](https://github.com/yihui/xaringan) which builds on [`remark.js`](https://remarkjs.com), [`knitr`](http://yihui.name/knitr), and [`RMarkdown`](https://rmarkdown.rstudio.com). The exercises were created with the [`unilur` package](https://github.com/koncina/unilur). Please make sure to properly cite all data that you use for your research (archives usually provide suggested citations). Also make sure to cite the free and open-source software (FOSS) that you use, such as `R` and the packages for it. To know how to do that, you can use the function `citation(packagename)` in `R`. We thank the *GESIS Training* team for taking good care of the organization of this course (and the whole Summer School) and all of you for participating!